//The Color class

#include "Color.h"

/*Color
*	The generic Color constructor.
*Parameters:
*	none
*/
Color::Color() {
	r = g = b = 0;
	a = 1;
}

/*Color
*	The initialized Color constructor.  Initializes to the given r, g, b values.
*Parameters:
*	float r	-> The r component
*	float g	-> The g component
*	float b	-> The b component
*/
Color::Color(float cr, float cg, float cb, float ca/* = 0 */) {
	r = cr;
	g = cg;
	b = cb;
	a = ca;
	
	boundColor();
}

/* * operator
*	Defines Color over multiplication by a scalar float.
*Parameters:
*	const Color scale	-> The scalar to multiply the color by
*Returns:
*	Color(pos*scale)	-> The new color
*/
Color Color::operator *(const float scale) {
	return Color(r*scale, g*scale, b*scale, a*scale);
}

/*Color Color::operator *(const Vector v) {
	return Color(r*v.x, g*v.y, b*v.z, a);
}*/

Color Color::operator *(const Color c) {
	return Color(r*c.r, g*c.g, b*c.b, a*c.a);
}

/*Color
*	The Color destructor.
*/
Color::~Color() {}

/* + operator
*	Defines Color over addition by another Color.
*Parameters:
*	const Color& c			-> The Color to be added
*Returns:
*	Color(r+c.r, g+c.g, b+c.b)	-> The new Color
*/
Color Color::operator +(const Color& c) {
	return Color(r+c.r, g+c.g, b+c.b, a+c.a);
}

/* << operator
*	Defines the printing of a Color
*Parameters:
*	const Color& c	-> The Color to be printed
*	ostream& os	-> The stream to send the Color to
*Returns:
*	ostream		-> The stream with the Color added to it
*/
ostream& operator << (ostream& os, const Color& c) {
	os << "(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
	return os;
}

/* boundColor
*	Makes sure the r, g, b, and a values of the color are between a given lowerBound
*	and upperBound.  The default values are 0 and 1.
*Parameters:
*	float lowerBound	-> The lower bound
*	float upperBound	-> The upper bound
*Returns:
*	none
*/
void Color::boundColor(float lowerBound/* = 0 */, float upperBound/* = 1 */) {
	r = max(lowerBound, min(upperBound, r));
	g = max(lowerBound, min(upperBound, g));
	b = max(lowerBound, min(upperBound, b));
	a = max(lowerBound, min(upperBound, a));
}

///* max
//*	Returns the max of two floats.
//*Parameters:
//*	float a	-> The first float
//*	float b	-> The second float
//*Returns:
//*	float	-> The maximum
//*/
//float Color::max(float a, float b) {
//	return (b<a)?a:b;
//}
//
///* min
//*	Returns the min of two floats.
//*Parameters:
//*	float a	-> The first float
//*	float b	-> The second float
//*Returns:
//*	float	-> The minimum
//*/
//float Color::min(float a, float b) {
//	return (b<a)?b:a;
//}